package com.xd.core.system.controller;


import com.xd.core.system.entity.Dictionary;
import com.xd.core.system.service.IDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 字典表 前端控制器
 * </p>
 *
 * @author SJ
 * @since 2023-03-24
 */
@Api(tags = "字典管理")
@RestController
@AllArgsConstructor
@RequestMapping("/core/dictionary")
public class DictionaryController {

    private IDictionaryService dictionaryService;
    @GetMapping("listByTypeH5")
    @ApiOperation(value = "H5页面客户_根据字典类型查询字典配置",notes = "-")
    public List<Dictionary> listByTypeH5(String type) {

        return this.dictionaryService.listByType(type);
    }

    @GetMapping("listByType")
    @ApiOperation(value = "客户_根据字典类型查询字典配置",notes = "-")
    public List<Dictionary> listByType(String type) {

        return this.dictionaryService.listByType(type);
    }

    @GetMapping("listByTypeCompany")
    @ApiOperation(value = "公司_根据字典类型查询字典配置",notes = "-")
    public List<Dictionary> listByTypeCompany(String type) {

        return this.dictionaryService.listByTypeCompany(type);
    }

    @PostMapping("listByTypes")
    @ApiOperation(value = "客户_根据字典类型查询字典配置",notes = "-")
    public List<Dictionary> listByTypes(@RequestBody List<String> types) {
        return this.dictionaryService.listByTypes(types);
    }

    @PostMapping("listByTypeAndCodes")
    @ApiOperation(value = "客户_根据字典类型和字典代码查询字典配置",notes = "-")
    public List<Dictionary> listByTypeAndCodes(@RequestBody List<String> codes,String type) {
        return this.dictionaryService.listByTypeAndCodes(codes,type);
    }
    @ApiOperation(value = "刷新缓存(字典，城市，模板)")
    @GetMapping("/flushed")
    public void flushed() {
        dictionaryService.flushed();
    }


}
